# 地图上显示伤害的类
class Window_MapDamage < Window_Base
  # 初始化
  def initialize
    super(0, 0, 640, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    self.back_opacity = 255
    refresh
  end

  # 刷新显示的内容
  def refresh
    self.contents.clear
    data = EnemyInfo.getCoordinate
    for it in data
      draw_item(it[0], it[1], it[2])
    end
  end

  # 描绘伤害文字
  def draw_item(eid, i, j)
    einfo = Game_EnemyInfo.new(eid)
    d = [einfo.getDamage, 99999].min
    if d == -1
      bitmap = RPG::Cache.windowskin("cloaked")
      rect = Rect.new(0, 0, bitmap.width, bitmap.height)
      self.contents.blt(i * 32 - 16, j * 32 + 4, bitmap, rect, 192)
      return
    end
    h = 85 - [d * 85 / ([$game_party.actors[0].hp, 0].max + 1), 85].min
    bitmap = RPG::Cache.windowskin("digits", h)
    a = d.to_s
    for k in 0...a.size
      rect = Rect.new(a[k, 1].to_i * 8, 0, 8, 12)
      self.contents.blt(i * 32 - (a.size - k) * 8 + 16, j * 32 + 4, bitmap, rect, 192)
    end
  end
end
